<?php 
$page = array('datePicker' => true);
$this->load->view('layout/adminHeader', $page); ?>
    
    <div id="mainContent" class="floatFix">
    	<?php $this->load->view('layout/adminToursSubmenu'); ?>
        
    	<div class="lCol">
           	<h2>Find tour(s)</h2>
            
            <form action="<?php echo site_url('tours'); ?>" method="post" id="searchForm" name="searchForm">
                <ul class="formContainer">
                	<fieldset>
                        <li class="floatFix">
                            <label>By tour ID</label>
                            <input type="text" class="smallInput" name="tourId" id="tourId" />
                        </li>
                        
                        <li style="text-align:center">OR</li>
                        
                        <li class="floatFix">
                            <label>By tour type</label>
                            <?php echo tourtypes_dropdown($tour_types, null, true); ?>
                        </li>
                    </fieldset>
                    
                    <fieldset>
                        <li class="floatFix">
                            <label>Departing On</label>
                            <input type="text" class="w8em format-d-m-y divider-slash range-low smallInput" id="departure_date" name="departure_date" />
                            <small><a href="#">Clear</a></small>
                        </li>
                        
                        <li style="text-align:center">OR</li>
                        
                        <li class="floatFix">
                            <label>In date range</label>
                        </li>
                        
                        <li class="floatFix">
                            <label>Start Date</label>
                            <input type="text" class="w8em format-d-m-y divider-slash range-low smallInput" id="start_date" name="start_date" />
                            <small><a href="#">Clear</a></small>
                        </li>
                        
                         <li class="floatFix">
                            <label>End Date</label>
                            <input type="text" class="w8em format-d-m-y divider-slash range-low smallInput" id="end_date" name="end_date" />
                            <small><a href="#">Clear</a></small>
                        </li>
                     </fieldset>
                    
                     <li class="floatFix">
                        <label>Active Only</label>
                        <input type="checkbox" class="checkbox" name="active_tours" id="active_tours" />
                    </li>
                    
                    <li class="floatFix">
                    	<input type="submit" class="submitButton" name="search" id="search" value="<?php if (isset($_POST['search'])) { echo 'Search Again!'; } else { echo 'Search Now!'; } ?>" />
                    </li>
                    
                </ul>
            </form>
            
            <?php
            if (isset($results)) { ?>
            <h3>Search Results</h3>
                        
            <table>
            	<thead>
                    <tr>
                      	<th>Tour Name</th>
                        
                        <th>Departure Date</th>
                        <th>Active</th>
                        <th></th>
                    </tr>
                </thead>
                
                <tbody>
                	<?php for ($i = 0; $i < count($results); $i++) { ?>
                    <tr>
                        <td><a href="<?php echo site_url('tours/show/' . $results[$i]['id']); ?>"><?php echo $results[$i]['tour_name']; ?> (<?php echo $results[$i]['tour_code']; ?>)</a></td>
                        
                        <td><?php echo natural_date_for_site($results[$i]['departure'], true); ?></td>
                        <td><?php echo yes_no($results[$i]['active']); ?></td>
                        <td><a href="<?php echo site_url('tours/edit/' . $results[$i]['id']); ?>">Edit</a></td>
                    </tr>
                    <?php } ?>
                   
                </tbody>
            </table>
            
            <?php } ?>
        </div>
        
        <div class="rCol">
        	<h2>Sidebar</h2>
        </div>
        
    </div>
    
<?php $this->load->view('layout/adminFooter'); ?>